#include <iostream>
#include <fraction.h>
using namespace std;

Fraction::Fraction(int d,int n)
{
    denom=d;num=n;
}


Fraction Fraction::simplify(Fraction &a)
{
    int m,n;
    if ( a.denom>a.num )
    {    m=a.denom; n=a.num;  }
    else
    {    m=a.num; n=a.denom;  }

    while( m/n != 0)
    {     m=n; n=m%n;   }

    return Fraction(a.denom/n,a.num/n);
}

Fraction Fraction::operator- (Fraction &a2)
{
    Fraction a;
    a.denom = denom * a2.denom;
    a.num = num * a2.denom + a2.num * denom;

    return Fraction::simplify( a );
}